import request from "@/utils/request.ts";
import { Permission, PermissionResponse } from "@/api/acl/permission/type.ts";

enum API {
  // /admin/acl/permission get 权限列表
  GET_PERMISSION_LIST = "admin/acl/permission",
  // /admin/acl/permission/save post 新增权限
  POST_ADD_PERMISSION = "admin/acl/permission/save",
  // PUT /admin/acl/permission/update put 修改权限
  PUT_UPDATE_PERMISSION = "admin/acl/permission/update",
  // /admin/acl/permission/remove/{id} delete 删除权限
  DELETE_PERMISSION = "admin/acl/permission/remove/",
}

// 获取权限列表
export const reqPermissionList = () =>
  request.get<any, PermissionResponse>(API.GET_PERMISSION_LIST);

// 新增权限
export const reqAddPermission = (data: Permission) =>
  request.post<any, any>(API.POST_ADD_PERMISSION, data);

// 修改权限
export const reqUpdatePermission = (data: Permission) =>
  request.put<any, any>(API.PUT_UPDATE_PERMISSION, data);

// 删除权限
export const reqDeletePermission = (id: number) =>
  request.delete<any, any>(API.DELETE_PERMISSION + id);
